﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Threading;
using VsSpeakerCompanion.UI;

namespace VsSpeakerCompanion.UI
{
    /// <summary>
    /// Interaction logic for LoginWindow.xaml
    /// </summary>
    internal partial class LoginWindow : Window
    {
        internal LoginWindow()
        {
            InitializeComponent();
        }

        private void CloseWindowAnimationCompleted(object sender, EventArgs e)
        {
            this.Close();
        }
       
        internal void CloseWithAnimation()
        {
            this.BeginStoryboard(this.FindResource("CloseWindowAnimation") as Storyboard);
        }

        /// <summary>
        /// Overrides KeyUp to handle the Escape key
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyUp(KeyEventArgs e)
        {
            base.OnKeyUp(e);

            if (e.Key == Key.Escape)
            {
                CloseWithAnimation();
                e.Handled = true;
            }
        }
    }
}